package com.king01.service.impl;

import com.king01.dao.StatisticsDao;
import com.king01.entity.CountVo;
import com.king01.entity.Staff;
import com.king01.service.StatisticsService;
import com.king01.vo.DateVo;
import com.king01.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author ：lqs
 * @date ：Created in 2023/10/9 17:21
 * @description：
 * @modified By：
 * @version:
 */
@Service
public class        StatisticsServiceImpl implements StatisticsService {
    @Autowired
    private StatisticsDao statisticsDao;
    @Autowired
    private HttpSession session;

    @Override
    public Result trade(DateVo dateVo) {
        Staff staff = (Staff)session.getAttribute("staff");
        dateVo.setBranchid(staff.getBranchid());
        List<Integer> trade = statisticsDao.trade(dateVo);
        return new Result(200,"查询成功",trade);
    }

    @Override
    public Result trade2(DateVo dateVo) {
        Staff staff = (Staff)session.getAttribute("staff");
        dateVo.setBranchid(staff.getBranchid());
        List<Integer> trade = statisticsDao.trade2(dateVo);
        return new Result(200,"查询成功",trade);
    }

    @Override
    public Result byBranch(DateVo dateVo) {
        List<Map> maps = statisticsDao.byBranch(dateVo);
        return new Result(200,"查询成功",maps);
    }

    @Override
    public Result byGoods(DateVo dateVo) {
        Staff staff = (Staff)session.getAttribute("staff");
        dateVo.setBranchid(staff.getBranchid());
        List<CountVo> countVos = statisticsDao.byGoods(dateVo);
        return new Result(200,"查询成功",countVos);
    }
}

